<?php if (isset($_GET['xhtml'])) { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--[if lt IE 7 ]> <html lang="it" class="no-js ie6" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 7 ]>    <html lang="it" class="no-js ie7" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 8 ]>    <html lang="it" class="no-js ie8" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 9 ]>    <html lang="it" class="no-js ie9" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="it" class="no-js" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"> <!--<![endif]-->
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<?php } else { ?>
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --> 
<!--[if lt IE 7 ]> <html lang="it" class="no-js ie6" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 7 ]>    <html lang="it" class="no-js ie7" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 8 ]>    <html lang="it" class="no-js ie8" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if IE 9 ]>    <html lang="it" class="no-js ie9" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="it" class="no-js" xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<?php } ?>

<title><?php echo isset($titolo_pagina) ? ($titolo_pagina . ' - ') : ''; ?>staSera? - Locali, eventi e biglietti a Pisa e dintorni</title>

<!--  Mobile viewport optimized: j.mp/bplateviewport -->
<!-- Disabilito, andrebbe provato <meta name="viewport" content="width=device-width, initial-scale=1.0" /> -->


<?php

require('min/utils.php');

if (isset($_GET['debug'])) {
?>
  <!-- Mantenere sincronizzato con min/groupsConfig.php -->
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/style.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/page_layout.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/colour.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/menu_hz.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/jplayer.blue.monday.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/boxgrid.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/awesome_buttons.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/dialogs.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/infiniteCarousel.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/selectBox.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/validationEngine.jquery.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/validationEngine.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/tipTip.css" />
  <link rel="stylesheet" href="<?php echo base_url().'/'; ?>css/sliding-panel-left.css" />
<?php } else { ?>
  <link rel="stylesheet" href="<?= base_url() . Minify_getUri('css') ?>" />
<?php } ?>

  <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/smoothness/jquery-ui.css" /> <!-- Tema jQuery UI -->

  <link rel="apple-touch-icon" href="<?= base_url() ?>apple-touch-icon.png" />

  <!-- Proprietà Open Graph -->
  <meta property="fb:app_id" content="<?= $facebook->getAppId() ?>" />
  <meta property="fb:admin" content="<?= $facebook->getAppId() ?>" />
  <meta property="og:site_name" content="staSera? - Eventi e locali a Pisa e dintorni" />
  <meta property="og:url" content="<?= current_url() ?>" />
  <?php if (isset($og_properties))
           foreach ($og_properties as $pname=>$pval) {
	     echo '<meta property="'.$pname.'" content="'.$pval.'" />';
  } ?>

<!-- All JavaScript at the bottom, except for Modernizr which enables HTML5 elements & feature detects -->
<!-- NB: per noi fa eccezione anche la libreria di Facebook -->
<?php if (isset($_GET['debug'])) { ?>
  <!-- Mantenere sincronizzato con min/groupsConfig.php -->
  <script src="<?php echo base_url().'/'; ?>js/libs/modernizr-1.7.min.js"></script>
<?php } else { ?>
  <script src="<?= base_url() . Minify_getUri('modernizr') ?>"></script>
<?php } ?>


</head>
<body onload="setupZoom()">


<!-- Carichiamo e inizializziamo l'SDK di Facebook appena possibile:
     per noi è vitale che le funzionalità legate a Facebook vengano caricate
     appena possibile, soprattutto per il parsing del XFBML e per la verifica
     della sessione.
-->
<div id="fb-root"></div>
<script src="<?php echo isset($_GET['debug']) ? '//static.ak.fbcdn.net/connect/en_US/core.debug.js' : '//connect.facebook.net/it_IT/all.js'; ?>"></script>
<script>// <![CDATA[
    var pagina_caricata = false;
    var pagina_aggiornata_per_fb = false;
    var fb_uid = null;
    var esegui_al_login = []; // E' possibile registrare funzioni da eseguire al login (esegui_al_login.push(funzione))

    function aggiorna_pagina_per_utente() {
	    if (pagina_aggiornata_per_fb)
		    return;
	    if (pagina_caricata) // Richiamiamo subito la funzione
		    fai_aggiornamento_pagina_per_utente();
	    // Altrimenti sarà fatto nel footer, controllando fb_uid
    }

    FB.init({
      appId   : '<?php echo $facebook->getAppId(); ?>',
      session : <?php echo json_encode($facebook->getSession()); ?>, // don't refetch the session when PHP already has it
      status  : true, // check login status
      cookie  : true, // enable cookies to allow the server to access the session
      xfbml   : true, // parse XFBML
      channelUrl : '<?php echo base_url(); ?>/channel.html'   // Usato per la comunicazione tra domini in qualche caso strano
    });

    FB.getLoginStatus(function(response) {
	<?php if (isset($_GET['debug'])) { ?>
	    log('getLoginStatus response: '); log(response);
	<?php } ?>
	    if (response.session) {
		    fb_uid = response.session.uid;
		    aggiorna_pagina_per_utente();
	    }
    });

    FB.Event.subscribe('auth.logout', function() { window.location.reload(); });
    // TODO: Necessario anche auth.sessionChange?
    //       Se facciamo tutte le richieste entro pochi minuti dal caricamento della pagina
    //       direi che possiamo ignorare la possibilità che scada la sessione.
    //       La sessione dovrebbe essere ripristinata anche server-side a ogni richiesta, credo.

    function fai_login_facebook(callback) {
	FB.login(function(response) {
	<?php if (isset($_GET['debug'])) { ?>
		log('FB.login response: '); log(response);
	<?php } ?>
		if (response.session) {
			if (response.perms) {
				fb_uid = response.session.uid;
				aggiorna_pagina_per_utente();
				if (callback)
					callback();
			} else {
				alert("Non sono stati concessi alcuni permessi. Se si verificano degli errori, provare ad effettuare il logout ed effettuare di nuovo l'accesso abilitando le funzionalità richieste.");
			}
		}
	}, {perms:'user_events,friends_events'});
	return false;
    }
	
    // ]]></script>

  <div id="container">
    <div id="header">
		<!--[if !(IE)]>-->
		<object type="application/x-shockwave-flash" data="<?php echo base_url().'/'; ?>flash/faces.swf" width="165" height="98" id="faces-flash" style="visibility: visible; "><param name="wmode" value="transparent" /><param name="flashvars" value="wmode=transparent" /></object>
        
		<object type="application/x-shockwave-flash" data="<?php echo base_url().'/'; ?>flash/header3.swf" width="360" height="240" id="header3-flash" style="visibility: visible; "><param name="wmode" value="transparent" /><param name="flashvars" value="wmode=transparent" /></object>
		<!--<![endif]-->
		
		<!--[if IE]> 
		<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="165" height="98" id="faces-flash">
			<param name="movie" value="<?php echo base_url().'/'; ?>flash/faces.swf" />
			<param name="flashvars" value="wmode=transparent" />
			<param name="wmode" value="transparent" />
		</object>
		<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="360" height="240" id="header3-flash">
			<param name="movie" value="<?php echo base_url().'/'; ?>flash/header3.swf" />
			<param name="flashvars" value="wmode=transparent" />
			<param name="wmode" value="transparent" />
		</object>
		<![endif]-->
		<h1><a href="<?php echo base_url(); ?>">STASERA?</a></h1>
     </div>
     <!--[if lt IE 7]> <div style=' clear: both; height: 59px; padding:0 0 0 15px; position: relative;'> <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode"><img src="http://www.theie6countdown.com/images/upgrade.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a></div> <![endif]--> 
   
	<!-- JCP: Macro div dei contenuti di sinistra -->

    <div id="column-left">
    	<a href="" style="float:left; width:30px; height:29px;" title="La nostra pagina Facebook" ><img src="<?php echo base_url().'/'; ?>images/jason/facebook.png" width="30" height="29" alt="La nostra pagina Facebook" /></a>
        <a href="" style="float:left; width:28px; height:29px;" title="Seguici su Twitter"><img src="<?php echo base_url().'/'; ?>images/jason/twitter.png"  width="28" height="29" alt="Seguici su Twitter" /></a>
        <a href="" style="float:left; width:44px; height:29px;" title="Guarda il nostro spazio Youtube con tutti i filmati"><img src="<?php echo base_url().'/'; ?>images/jason/youtube.png"  width="44" height="29" alt="Il nostro spazio Youtube" /></a>
        <div id="nav">
		<form action="<?= site_url('stasera/cerca') ?>" id="form_ricerca" method="get" accept-charset="utf-8">
        	<ul>
          		<li id="a"><div id="searchBox">
	                    <input type="search" name="q" id="s1" placeholder="Cerca eventi, pub, discoteche, date&#8230;"  />
	                </div></li>
          		<li id="b"><a href="javascript:document.forms['form_ricerca'].submit()" class="on">Cerca!</a></li>
         	</ul>
		</form>
        </div>
        <div id="content">
			<div class="menu_icons">
				<img style="padding-left:25px; z-index: 1;" src="<?php echo base_url().'/'; ?>images/menu_icons/Facebook-32.png" alt="Facebook" />
			</div>
			<div class="menu_icons" style="left:225px; z-index: 1;">
				<img src="<?php echo base_url().'/'; ?>images/menu_icons/Empty-shopping-cart-32.png" alt="Carrello" />
			</div>
			<div class="menu_icons" style="left:380px; z-index: 1;">
				<img src="<?php echo base_url().'/'; ?>images/menu_icons/Pencil-32.png" alt="Contattaci" />
			</div>
			<div class="menu_icons" style="left:510px; z-index: 1;">
				<img src="<?php echo base_url().'/'; ?>images/menu_icons/Help-32.png" alt="Info" />
			</div>
			<div id="menu">
				<ul class="menu">
					<li class="active"><a id="comando_login_fb" href="#" onclick="fai_login_facebook();"><span id="comando_login_fb_span">Login con facebook</span></a></li>
					<li style="position: absolute; left: 205px; top: 0px;"><a href="#dialog" class="modal"><span>Il tuo carrello</span></a></li>
					<li style="position: absolute; left: 355px; top: 0px;"><a href="#dialog_contattaci" class="modal"><span>Contattaci</span></a></li>
					<li style="position: absolute; left: 485px; top: 0px;"><a href="<?php echo site_url('simple/chisiamo');?>"><span>Info</span></a></li>
				</ul>
			</div>

			<!-- Usati per mostrare errori o simili -->
			<div id="messaggi_errore_ajax" class="ui-widget" style="display: none;">
				<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
					<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span> 
					<span id="testo_messaggio_errore_ajax"></span></p>
				</div>
			</div>
			<div id="messaggi_info_ajax" class="ui-widget" style="display: none; margin: 1em; padding: 0.3em;">
				<div class="ui-state-highlight ui-corner-all" style="padding: 0 .7em;"> 
					<p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
					<span id="testo_messaggio_info_ajax"></span></p>
				</div>
			</div>

